package com.yuan.system.api.client;

import cn.common.constant.ServiceNameConstants;
import cn.model.Member;
//import com.yuan.system.api.factory.RemoteMemberFallbackFactory;

//import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
//import io.github.resilience4j.timelimiter.annotation.TimeLimiter;

import com.yuan.system.api.factory.RemoteMemberFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


import java.util.List;
import java.util.concurrent.CompletableFuture;

//
@FeignClient(contextId = "RemoteUserClient", name = ServiceNameConstants.MEMBER_SERVICE,fallbackFactory= RemoteMemberFallbackFactory.class)
public interface RemoteUserClient {
    @GetMapping("/member/info/{phone}")
//    @CircuitBreaker(name = "memberServiceCircuitBreaker") //, fallbackMethod = "fallbackGetUserInfo"
//    @TimeLimiter(name = "memberServiceTimeLimiter")
    CompletableFuture<List<Member>> getUserInfo(@PathVariable("phone") String phone);

//    default CompletableFuture<List<Member>> fallbackGetUserInfo(Throwable t) {
//        System.out.println("Fallback due to: " + t.getMessage());
//        throw new RuntimeException("系统异常");
//       // return CompletableFuture.completedFuture(Collections.emptyList());
//    }

}
